<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>添加菜单</title>
    <link rel="stylesheet" href="/asset/layui/css/layui.css">
    <link rel="stylesheet" href="/asset/css/index.css">
    <link rel="Shortcut Icon" href="cachet.ico">
    <script type="text/javascript" src="/asset/js/jquery-3.3.1.min.js"></script>
	<script src="/asset/layui/layui.js"></script>
    <script src="/asset/js/common.js"></script>
</head>
<body>
<div class="alert_bigbox">

	<form class="layui-form">
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>上一级菜单
              </label>
              <div class="layui-input-inline">
                   <select name="parentId" lay-filter="city">
	                <option value="0">一级菜单</option>
	                <#list menus as item>
	                <option value="${item.menuId}" <#if item.menuId==parentId>selected</#if>>${item.menuName}</option>
	                </#list>
	              </select>
              </div>
          </div>
          
          <div class="layui-form-item">
              <label for="password" class="layui-form-label">
                  <span class="x-red">*</span>菜单名称
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="menuName" name="menuName" required="" placeholder="请输入菜单名称" lay-verify="menuName" autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux"></div>
          </div>
  
          <div class="layui-form-item">
              <label for="name" class="layui-form-label">
                  <span class="x-red">*</span>菜单编号
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="menuCode" name="menuCode" value="" placeholder="请输入菜单编码" required="" lay-verify="menuCode" autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
              	如：ADMIN_INDEX 必须唯一
              </div>
          </div>
          
          <div class="layui-form-item">
              <label for="name" class="layui-form-label">
                  <span class="x-red">*</span>访问地址
              </label>
              <div class="layui-input-inline" style="width:300px">
                  <input type="text" id="actions" name="actions" value="" required="" placeholder="请输访问地址" lay-verify="actions" autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux"> 如：/admin/user.htm ，一级目录可以为空</div>
          </div>
          <div class="layui-form-item">
              <label for="name" class="layui-form-label">
                  <span class="x-red">*</span>顺序
              </label>
              <div class="layui-input-inline" style="width:50px">
                  <input type="text" id="sequence" name="sequence" value="0" required="" lay-verify="menuCode" autocomplete="off" class="layui-input">
              </div>
          </div>
          
          <div class="layui-form-item">
              <label for="name" class="layui-form-label">
                  是否启用
              </label>
              <div class="layui-input-inline">
              	<input type="checkbox"  checked value="Y" id="isEnable" name="isEnable" lay-skin="switch" lay-filter="switchTest" lay-text="禁用|启用">
              </div>
          </div>
         
          <div class="layui-form-item">
              <label for="name" class="layui-form-label">
              </label>
              <div class="layui-input-inline">
              <button  class="layui-btn" lay-filter="add" lay-submit="">增加</button>
              </div>
          </div>
      </form>

</div>

    <script>
        layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;
        	 

          //监听提交
          form.on('submit(add)', function(data){
          
            $.ajax({
      			type:"POST", 
      			url:"/admin/menu/create.htm",
      			data:data.field,
      			success:function(result) {
		      
		      		if(result.code=='1'){
		      			layer.alert("增加成功", {icon: 6},function () {
			                // 获得frame索引
			                 window.parent.location.reload();
			                var index = parent.layer.getFrameIndex(window.name);
			                //关闭当前frame
			                parent.layer.close(index);
			            });
		      		}else{
		      		 	layer.msg(result.msg);
		      		}
		      
		    	 	} 
		    }); 
            
            return false;
          });
          
        });
    </script>

</body>
</html>